const information = document.getElementById("info");
information.innerText = `This app is using Chrome (v${window.versions.chrome()}), Node.js (v${window.versions.node()}), and Electron (v${window.versions.electron()})`;
document.getElementById("addWindowBtnId").addEventListener("click", () => {
    window.versions.sendMessage("addBrowserWindow");
});
document.getElementById("openKeyboardBtnId").addEventListener("click", () => {
    window.versions.sendMessage("openKeyboard");
});
document.getElementById("addNestWindowBtnId").addEventListener("click", () => {
    window.versions.sendMessage("addBrowserView");
});
const func = async () => {
    console.log("项目启动");
    const response = await window.versions.invokeMessage();
    console.log(response, "response");
};
func();
// 监听主进程发送的数据
window.versions.mainToRend((arg) => {
    console.log(arg, "arg");
    const imgBox = document.createElement("div");
    imgBox.className = "imgBox";
    arg.forEach((item) => {
        const img = document.createElement("img");
        img.src = `data:image/*;base64,${item}`;
        imgBox.appendChild(img);
    });
    const wrapper = document.getElementById("imgListId");
    wrapper.appendChild(imgBox);
});
const videoElement = document.getElementById("videoId");
videoElement.addEventListener("ended", () => {
    console.log("视频播放完毕");
    // 重新加载
    // videoElement.load();
    console.log(videoElement.currentSrc);
    videoElement.src = videoElement.currentSrc;
});
videoElement.addEventListener("error", (target, error) => {
    console.log(target, "target");
    console.log(error, "error");
});
